﻿cmake_minimum_required (VERSION 3.8)
project ("MainPro")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_BUILD_TYPE "Release")

find_package(Qt5 COMPONENTS Core Gui Widgets Quick QuickWidgets REQUIRED)
find_package(spdlog REQUIRED)

#添加所有的头文件,源文件,ui文件,资源文件
file(GLOB HEADERS sources/*.h ${CMAKE_SOURCE_DIR}/include/*.h)
file(GLOB SOURCE_FILES sources/*.cpp)
file(GLOB FORMS sources/*.ui)
file(GLOB RESOURCES resource/*.qrc)

# 设置生成的项目筛选器
source_group("Header Files" FILES ${HEADERS})
source_group("Source Files" FILES ${SOURCE_FILES})
source_group("Resource Files" FILES ${RESOURCES})
source_group("Form Files" FILES ${FORMS})
source_group("Translation Files" FILES ${TRANSLATIONS})

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

add_executable (${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCE_FILES} ${FORMS} ${RESOURCES})

set(DLL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dll")
link_directories(${DLL_DIR}) #指定库的搜索路径
#message(STATUS "DLL Directory: ${DLL_DIR}")


target_include_directories(MainPro PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/docksrc")
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_link_libraries(MainPro PRIVATE "${DLL_DIR}/qtadvanceddockingd.lib")
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
target_link_libraries(MainPro PRIVATE "${DLL_DIR}/qtadvanceddocking.lib")
endif ()
target_link_libraries(MainPro PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::QuickWidgets)
target_link_libraries(MainPro PRIVATE spdlog::spdlog)
#add_subdirectory(../MyLibrary MyLibrary_build)
#target_link_libraries(MainPro PRIVATE MyLibrary)
#add_library(Dmc1000 STATIC IMPORTED)
#set_target_properties(Dmc1000 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/dll/Dmc1000.lib)
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
#target_link_libraries(${PROJECT_NAME} Dmc1000)
#target_link_libraries(${PROJECT_NAME} libzmq libzmq)

set_target_properties(MainPro PROPERTIES 
    CXX_STANDARD 14
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
)

# TODO: 如有需要，请添加测试并安装目标。
